package scale
{
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.geom.Rectangle;

	public class ScaleAll
	{
		private var root:Stage;
		public function ScaleAll(root:Stage)
		{
			this.root = root;
			//alignCenter();
			slaceWH();
		}
		
		private function slaceWH():void
		{
			var con:Sprite = new Sprite();
			con.graphics.beginFill(0x111fff);
			con.graphics.drawRect(0, 0, 310, 210);
			con.graphics.endFill();
			root.addChild(con);
			
			var child:Sprite = new Sprite();
			child.graphics.beginFill(0xccab21);
			child.graphics.drawRect(0, 0, 100, 130);
			child.graphics.endFill();
			con.addChild(child);
		}
		
		private function alignCenter():void
		{
			var con:Sprite = new Sprite();
			con.graphics.beginFill(0x111fff);
			con.graphics.drawRect(15, 60, 210, 210);
			con.graphics.endFill();
			root.addChild(con);
			
			var cr:Rectangle = con.getRect(con);
			
			var ap:Picture = new Picture(0x8a6b21, 10, 70, 200, 200);
			var ar:Rectangle = ap.getRect(ap);
			
			//居中
			ap.x += (con.width - ap.width) / 2 + (cr.x - ar.x);
			ap.y += (con.height - ap.height) / 2 + (cr.y - ar.y);
			con.addChild(ap);
		}
	}
}